
//app.js
App({
  onLaunch: function () {
    //调用API从本地缓存中获取数据
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

  },
  getUserInfo: function (cb) {
    var that = this
    if (this.globalData.userInfo) {
      typeof cb == "function" && cb(this.globalData.userInfo)
    } else {
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },
  globalData: {
    _new_url: 'https://zskjapp.cn/',
    // _new_url: 'http://192.168.1.113:8088/',
    userInfo: null,
    userInfos: null,
    foods: null,
    foods2: null,
    foodstype: null,
    totalprice: 0.00,
    appid: '',
    secret: '', 
    openId: null,
    id: 0,
    ordertype: 1,
    ydid: null,
    dpxinxi: null,
    num: 0,
    shopids: 'f170562e-d63f-4833-957a-f7727aab9968',
    table: 0,
    jixu: false,
    xlmy: false,
    chooseCurrentProductId: '',
    chooseCurrentProductNumber: 0,
    list: null,
    slist: null,
    deskid: '',
    NumberId: '',
    category_id: '', //分页id
    desk_open: false,
    shop_name: '',
    isDiancanFlow: 1,
    shop_infos: [],
    appointmentId: '',  //预约id
    Freight: '',  //运费
    NoNeedCheckDeskNo: true,
  },
  returnFloat: function (value) {
    var value = Math.round(value * 100) / 100;
    var xsd = value.toString().split(".");
    if (xsd.length == 1) {
      value = value.toString() + ".00";
      return value;
    }
    if (xsd.length > 1) {
      if (xsd[1].length < 2) {
        value = value.toString() + "0";
      }
      return value;
    }
  }
})